package com.msb.userclient;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author DreamAndLove
 * @date 2024/09/05 16:26
 * @description
 */
@SpringBootApplication
@EnableFeignClients
@EnableHystrixDashboard
public class UserConsumerApplication {
    public static void main(String[] args) {
        /*
         * 用了@EnableHystrixDashboard注解，可以访问 http://XXXX:port/hystrix来查看断路的面板了，
         * 输入 http://XXXX:port/actuator/hystrix.stream，作为监控对象，
         * 这个路径来自于actuator的健康检查相关配置
         */
        SpringApplication.run(UserConsumerApplication.class, args);
    }

    /**
     * 功能:为了让restTemplate的降级方法生效，在主类上添加了@EnableCircuitBreaker注解
     * @author DreamAndLove
     * @return RestTemplate
     * @date 2024/9/6 16:29
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
